package com.ardf.mapper;

import com.ardf.entity.Number;
import com.ardf.entity.dto.DownloadNumberDto;
import com.ardf.entity.dto.NumberSearchAllDto;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author ShiYunHao
 * @since 2025-01-06
 */
public interface NumberMapper extends BaseMapper<Number> {
    /**
     * 有条件分页
     */
    Page<NumberSearchAllDto> searchAll(@Param("page") Page<NumberSearchAllDto> page,
                                       @Param("competitionId") Long competitionId,
                                       @Param("searchAll") String searchAll);

    /**
     * 根据GroupId获取
     */
    @Select("select n.* from number as n inner join athlete as a on n.athlete_id=a.id where a.group_id=#{groupId}")
    List<Number> listByGroupId(@Param("groupId") Long groupId);

    long check(@Param("competitionId")Long competitionId,@Param("number") String number,@Param("numberId") Long numberId);

    /**
     * 获取同意赛事的所有选手号码
     */
    List<DownloadNumberDto> getAll(Long competitionId);

    List<Number> containsEmpty(@Param("competitionId") Long competitionId);
}
